package com.hydl.power.service.impl;

import com.hydl.power.mapper.PowerImageMapper;
import com.hydl.power.mapper.SysUserMapper;
import com.hydl.power.pojo.PowerImage;
import com.hydl.power.pojo.SysUser;
import com.hydl.power.service.PowerImageService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class PowerImageServiceImpl implements PowerImageService {

    @Autowired
    private PowerImageMapper powerImageMapper;

    @Autowired
    private SysUserMapper userMapper;


    @Override
    public List<PowerImage> getPowerImage(String token) {
        List<PowerImage> list=new ArrayList<>();
        if (StringUtils.isNotBlank(token)){

            SysUser user = userMapper.getUserByToken(token);
            if (user!=null){
                if (user.getStatus()!=2){
                   list = powerImageMapper.getPowerImageList(null);
                }else {
                    list = powerImageMapper.getPowerImageList(user.getProjectId());
                }
            }
        }
        return list;
    }

}
